|
|
|
|
Tabs and Associated Controls |
SftTabs/NET offers two distinct methods to manage controls associated with a tab:
Based on the presence of a client area, controls can be added to the tab’s client area at design-time. The client area is used to display controls associated with each tab. During design-time and at run-time, switching between tabs exposes the associated controls. As the user switches between tabs, the control associated with each tab is shown or hidden. As controls are hidden because their associated tab is not the current tab, the controls are not only hidden, but also disabled. This is fully automatic and requires no application intervention.
Each tab page can host exactly one control. When clicking on a different tab, the new tab page becomes active and the associated control becomes visible and active. If you want to use multiple controls on one tab page, simply add a SftTabsPanel or Panel control as the tab's associated control. The SftTabsPanel (or Panel) control can then in turn host any number of controls. You can also take advantage of the SftTabsPanel (or Panel) control's docking and layout features, so implementing resizable forms with tab controls and nested tab pages is a snap.
The Features sample shows how a tab control is used to contain associated controls.
The application receives a Switching event as the currently active tab changes. The Switching event allows an application to prevent the change to the new current tab. Once a new tab page is active, the Switched event occurs.
The tab order of the controls contained within the client area (or current tab page) is defined using each control'zs TabIndex property.
If a client area is not present, SftTabs/NET does not maintain associated controls. The tab control can then be used (under application control) to cause some sort of data switching or to activate other objects, such as forms or controls.
The included Scribble sample demonstrates how a tab control can be used to switch between MDI child windows of an MDI application. The TabForm sample also uses a tab control without client area.
The TabClass.Tag1 (and Tag2) property is particularly useful in this context, as it allows an application to store a reference to an object, usually a form, with each tab. This provides easy access to and management of objects that are controlled by the application in response to events generated by the tab control.
The application receives a Switching event as the currently active tab changes. The Switching event allows an application to prevent the change to the new current tab. Once a new tab page is active, the Switched event occurs.